<?php 
namespace V1\Model;

use Think\Model;
class FriendsModel extends Model
{
	/**
	 * 添加好友
	 * @param string|int $userId
	 * @param string|int $friendId
	 * @param string|int $source
	 * @return boolean|\Think\mixed
	 */
	public function addFriend($userId, $friendId, $source) {
		
		$count = $this->where(array('user_id' => $userId, 'friend_id' => $friendId))->count();
		
		if(!empty($count)) return false;

		$row['user_id'] = $userId;
		$row['friend_id'] = $friendId;
		$row['status'] = 1;
		$row['src'] = $source;
		$row['create_time'] = NOW_TIME;
		$row['update_time'] = NOW_TIME;
		return $this->add($row);
	}
}


?>